<?php
//No direct access
defined('_JEXEC') or die('Restricted access');
?>
<script type="text/javascript">
	function viewdate( datetime ) {
		var f = document.adminForm;
		f.date.value= datetime;
		if (typeof f.onsubmit == "function") {
				f.onsubmit();
		}
		f.submit();
	}
</script>
<div id="ownservices">
 <div id="mainmenuownservice"><?php echo MenuHelper::nav(); ?></div>
	<div id="mainownservice">
		<h3><?php echo JText::_('OWNSERVICE_TRANSFER_HISTORYS'); ?></h3>
		<hr />
		<?php echo JText::_('OWNSERVICE_DATE').' '.$this->date; ?>
		<form name="adminForm" method="post" action="<?php echo JRoute::_('index.php?option=com_ownservice'); ?>">
		<table class="adminlist" cellspacing="1">
			<thead>
				<tr>
					<th width="15%">Day</th>
					<th>AUD</th>
					<th>THB</th>
				</tr>
			</thead>
			<tbody>
				<?php
				$priceformat 	= OwnserviceHelper::getParams('price_format', '#,###.##');
				$k=0;
				$allamount	= 0;
				$alltotal		= 0;
				for($i=0, $n=count($this->rows); $i < $n; $i++):
					$row	= $this->rows[$i];

					list($date, $time) = explode(' ', $row->requested_date);
				?>
				<tr class="<?php echo "row$k"; ?>">
					<td align="center">
						<a href="javascript:void(0);" onclick="return viewdate('<?php echo $date; ?>')">
						<?php echo JHTML::_('date', $row->requested_date, '%Y-%m-%d'); ?>
						</a>
					</td>
					<td align="right"><?php echo OwnserviceHelper::moneyFormat($priceformat,$row->sumamount); ?></td>
					<td align="right"><?php echo OwnserviceHelper::moneyFormat($priceformat,$row->sumtotal); ?></td>
				</tr>
				<?php 
						$k = 1 - $k;
						$allamount += $row->sumamount;
						$alltotal	   += $row->sumtotal;
					endfor; 
				?>
				<tr>
					<td></td>
					<td align="right"><strong><?php echo OwnserviceHelper::moneyFormat($priceformat,$allamount); ?></strong></td>
					<td align="right"><strong><?php echo OwnserviceHelper::moneyFormat($priceformat,$alltotal); ?></strong></td>
				</tr>
			</tbody>
		</table>
		<input type="hidden" name="date" value="" />
		<input type="hidden" name="option" value="com_ownservice" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="layout" value="transferdate" />
		<input type="hidden" name="Itemid" value="<?php echo JRequest::getVar('Itemid'); ?>" />
		<input type="hidden" name="controller" value="transferhistory" />
		<input type="hidden" name="view" value="transferhistories" />
		<?php echo JHTML::_( 'form.token' ); ?>
		</form>
	</div>
</div>